//
// Created by 郝羽 on 2018/6/25.
//

#include "config.hpp"

#include <string>

Context::Context() {
    workers = 1;
    logConfigFile = nullptr;
    concurrency = 1;
    rampUpSeconds = 1;
    durationSeconds = 60;
    verbosity = 0;
    minMediaPort = 10000;
    maxMediaPort = 65535;
    video_bitrate = 500000;
    sequence = Sequence::Offerer;
    replace_candidate = false;
    mixer_id = nullptr;
    subscribe_self = true;
    child = false;
    n_pub = 0;
}

std::string Context::toString() const {
    std::ostringstream writer;
    writer << "log config file: " << (logConfigFile == nullptr ? "null"
            : std::string(logConfigFile)) << std::endl;
    for (auto& a : rtcAddresses) {
        writer << "rtc server: " << a << std::endl;
    }
    writer << "local media address: " << mediaAddress << std::endl;
    writer << "concurency: " << concurrency << std::endl;
    writer << "ramp-up-seconds: " << rampUpSeconds << std::endl;
    writer << "duration-seconds: " << durationSeconds << std::endl;
    writer << "verbosity: " << verbosity << std::endl;
    writer << "media-port-range: " << minMediaPort << "-" << maxMediaPort << std::endl;
    writer << "video-bitrate: " << video_bitrate << std::endl;
    writer << "replace-candidate: " << (replace_candidate ? "yes" : "no") << std::endl;
    writer << "mixer-id: " << (mixer_id != nullptr ? std::string(mixer_id) : "null") << std::endl;
    return std::string(writer.str());
}
